package com.netty.source_code.bytebuf;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author xl-9527
 * @since 2025/7/16
 **/
public class ByteBufDemo {

    private static final Logger log = LoggerFactory.getLogger(ByteBufDemo.class);

    public static void main(String[] args) {
        final ByteBuf byteBuf = Unpooled.directBuffer(10);

        byteBuf.writeBytes(new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
        log.info("byteBuf: {}",  byteBuf.writerIndex() - byteBuf.readerIndex());
        byteBuf.writeInt(20);
        log.info("byteBuf: {}",  byteBuf.writerIndex() - byteBuf.readerIndex());
        final int anInt = byteBuf.getInt(11);
        log.info("byteBuf get int: {}", anInt);
    }
}
